package com.fight.strive.sys.modules.scheduler.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fight.strive.sys.modules.common.BaseEntity;
import com.fight.strive.sys.modules.validator.StriveNotBlank;
import com.fight.strive.sys.modules.validator.StriveNotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;


@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Entity
@Table(name = "t_sys_sch_job",
        indexes = {
                @Index(columnList = "execId"),
                @Index(columnList = "execCode"),
                @Index(columnList = "status")})
@TableName("t_sys_sch_job")
public class SchJobEntity extends BaseEntity {

    /**
     * 执行器ID
     */
    @StriveNotBlank(msg = "没有选择执行")
    private String execId;

    /**
     * 执行器编号
     */
    private String execCode;

    /**
     * 执行器名称
     */
    private String execName;

    /**
     * 任务编号
     */
    @Column(unique = true)
    @StriveNotBlank(msg = "任务编号为空")
    private String code;

    /**
     * 任务名称
     */
    @StriveNotBlank(msg = "任务名称为空")
    private String name;

    /**
     * 任务路径
     */
    @StriveNotBlank(msg = "任务路径为空")
    private String path;

    /**
     * cron 表达式
     */
    @StriveNotBlank(msg = "cron表达式为空")
    private String cron;

    /**
     * 负责人姓名
     */
    @StriveNotBlank(msg = "负责人姓名为空")
    private String person;

    /**
     * 邮件通知
     */
    @StriveNotBlank(msg = "负责人邮箱为空")
    private String email;

    /**
     * 任务参数
     */
    private String params;

    /**
     * 任务是否启动，RUNNING,STOPED
     */
    private String status;

    /**
     * 重试次数
     */
    @StriveNotNull(msg = "任试次数为空")
    private Integer retry;

    /**
     * 任务描述
     */
    @Column(columnDefinition = "text")
    private String jobDesc;
}
